********************************************************************************
*Figure B7; Panel A
********************************************************************************
clear all
set matsize 10000
set maxvar 40000
set more off
global data " "
global dir " "
use $data/estimation_sample_blacks, clear

gen plus0=0
replace plus0=1 if index==0
gen plus1=0
replace plus1=1 if index==1
gen plus2=0
replace plus2=1 if index==2
gen plus3=0
replace plus3=1 if index==3
gen plus4=0
replace plus4=1 if index>=4


gen minus1=0
replace minus1=1 if index==-1
gen minus2=0
replace minus2=1 if index==-2
gen minus3=0
replace minus3=1 if index==-3
gen minus4=0
replace minus4=1 if index==-4
gen minus5=0
replace minus5=1 if index<=-5
ivregress 2sls         newbw2500 plus0 plus1 plus2 plus3 plus4   minus2 minus3 minus4 minus5 (elig00=simu00) i.year i.birth_month  i.by i.age_cat  i.mom_birth_state   i.tbo i.male   Exitexam Perstudentexpenditure Studentteacherratio Povertyrate Unemploymentrate i.division#c.by   , cluster(mom_birth_state)
matrix V= e(V)
matrix a = V[1..9,1..9]
svmat a

global var1=a1[1]
gen sd1=sqrt($var1)
global var2=a2[2]
gen sd2=sqrt($var2)
global var3=a3[3]
gen sd3=sqrt($var3)
global var4=a4[4]
gen sd4=sqrt($var4)
global var5=a5[5]
gen sd5=sqrt($var5)
global var6=a6[6]
gen sd6=sqrt($var6)
global var7=a7[7]
gen sd7=sqrt($var7)
global var8=a8[8]
gen sd8=sqrt($var8)
global var9=a9[9]
gen sd9=sqrt($var9)

gen lower1=_b[plus0]-(1.96*sd1)
gen upper1=_b[plus0]+(1.96*sd1)

gen order=0

gen value=_b[plus0]

keep if _n==1

keep lower1 upper1 order value


tempfile conf1

save "`conf1'"


*2
use $data/estimation_sample_blacks, clear

gen plus0=0
replace plus0=1 if index==0
gen plus1=0
replace plus1=1 if index==1
gen plus2=0
replace plus2=1 if index==2
gen plus3=0
replace plus3=1 if index==3
gen plus4=0
replace plus4=1 if index>=4


gen minus1=0
replace minus1=1 if index==-1
gen minus2=0
replace minus2=1 if index==-2
gen minus3=0
replace minus3=1 if index==-3
gen minus4=0
replace minus4=1 if index==-4
gen minus5=0
replace minus5=1 if index<=-5
ivregress 2sls newbw2500 plus0 plus1 plus2 plus3 plus4   minus2 minus3 minus4 minus5 i.year (elig00=simu00) i.birth_month  i.by i.age_cat  i.mom_birth_state   i.tbo i.male   Exitexam Perstudentexpenditure Studentteacherratio Povertyrate Unemploymentrate i.division#c.by   , cluster(mom_birth_state)

matrix V= e(V)
matrix a = V[1..9,1..9]
svmat a

global var1=a1[1]
gen sd1=sqrt($var1)
global var2=a2[2]
gen sd2=sqrt($var2)
global var3=a3[3]
gen sd3=sqrt($var3)
global var4=a4[4]
gen sd4=sqrt($var4)
global var5=a5[5]
gen sd5=sqrt($var5)
global var6=a6[6]
gen sd6=sqrt($var6)
global var7=a7[7]
gen sd7=sqrt($var7)
global var8=a8[8]
gen sd8=sqrt($var8)
global var9=a9[9]
gen sd9=sqrt($var9)

gen lower1=_b[plus1]-(1.96*sd2)
gen upper1=_b[plus1]+(1.96*sd2)

gen order=1

gen value=_b[plus1]

keep if _n==1

keep lower1 upper1 order value

tempfile conf2

save "`conf2'"


*3
use $data/estimation_sample_blacks, clear

gen plus0=0
replace plus0=1 if index==0
gen plus1=0
replace plus1=1 if index==1
gen plus2=0
replace plus2=1 if index==2
gen plus3=0
replace plus3=1 if index==3
gen plus4=0
replace plus4=1 if index>=4


gen minus1=0
replace minus1=1 if index==-1
gen minus2=0
replace minus2=1 if index==-2
gen minus3=0
replace minus3=1 if index==-3
gen minus4=0
replace minus4=1 if index==-4
gen minus5=0
replace minus5=1 if index<=-5
ivregress 2sls newbw2500 plus0 plus1 plus2 plus3 plus4   minus2 minus3 minus4 minus5 i.year (elig00=simu00) i.birth_month  i.by i.age_cat  i.mom_birth_state   i.tbo i.male   Exitexam Perstudentexpenditure Studentteacherratio Povertyrate Unemploymentrate i.division#c.by   , cluster(mom_birth_state)

matrix V= e(V)
matrix a = V[1..9,1..9]
svmat a

global var1=a1[1]
gen sd1=sqrt($var1)
global var2=a2[2]
gen sd2=sqrt($var2)
global var3=a3[3]
gen sd3=sqrt($var3)
global var4=a4[4]
gen sd4=sqrt($var4)
global var5=a5[5]
gen sd5=sqrt($var5)
global var6=a6[6]
gen sd6=sqrt($var6)
global var7=a7[7]
gen sd7=sqrt($var7)
global var8=a8[8]
gen sd8=sqrt($var8)
global var9=a9[9]
gen sd9=sqrt($var9)

gen lower1=_b[plus2]-(1.96*sd3)
gen upper1=_b[plus2]+(1.96*sd3)

gen order=2

gen value=_b[plus2]

keep if _n==1

keep lower1 upper1 order value


tempfile conf3

save "`conf3'"

*4
use $data/estimation_sample_blacks, clear

gen plus0=0
replace plus0=1 if index==0
gen plus1=0
replace plus1=1 if index==1
gen plus2=0
replace plus2=1 if index==2
gen plus3=0
replace plus3=1 if index==3
gen plus4=0
replace plus4=1 if index>=4


gen minus1=0
replace minus1=1 if index==-1
gen minus2=0
replace minus2=1 if index==-2
gen minus3=0
replace minus3=1 if index==-3
gen minus4=0
replace minus4=1 if index==-4
gen minus5=0
replace minus5=1 if index<=-5
ivregress 2sls newbw2500 plus0 plus1 plus2 plus3 plus4   minus2 minus3 minus4 minus5 i.year (elig00=simu00) i.birth_month  i.by i.age_cat  i.mom_birth_state   i.tbo i.male   Exitexam Perstudentexpenditure Studentteacherratio Povertyrate Unemploymentrate i.division#c.by   , cluster(mom_birth_state)

matrix V= e(V)
matrix a = V[1..9,1..9]
svmat a

global var1=a1[1]
gen sd1=sqrt($var1)
global var2=a2[2]
gen sd2=sqrt($var2)
global var3=a3[3]
gen sd3=sqrt($var3)
global var4=a4[4]
gen sd4=sqrt($var4)
global var5=a5[5]
gen sd5=sqrt($var5)
global var6=a6[6]
gen sd6=sqrt($var6)
global var7=a7[7]
gen sd7=sqrt($var7)
global var8=a8[8]
gen sd8=sqrt($var8)
global var9=a9[9]
gen sd9=sqrt($var9)

gen lower1=_b[plus3]-(1.96*sd4)
gen upper1=_b[plus3]+(1.96*sd4)

gen order=3

gen value=_b[plus3]

keep if _n==1

keep lower1 upper1 order value


tempfile conf4

save "`conf4'"

*5

use $data/estimation_sample_blacks, clear

gen plus0=0
replace plus0=1 if index==0
gen plus1=0
replace plus1=1 if index==1
gen plus2=0
replace plus2=1 if index==2
gen plus3=0
replace plus3=1 if index==3
gen plus4=0
replace plus4=1 if index>=4


gen minus1=0
replace minus1=1 if index==-1
gen minus2=0
replace minus2=1 if index==-2
gen minus3=0
replace minus3=1 if index==-3
gen minus4=0
replace minus4=1 if index==-4
gen minus5=0
replace minus5=1 if index<=-5
ivregress 2sls newbw2500 plus0 plus1 plus2 plus3 plus4   minus2 minus3 minus4 minus5 i.year (elig00=simu00) i.birth_month  i.by i.age_cat  i.mom_birth_state   i.tbo i.male   Exitexam Perstudentexpenditure Studentteacherratio Povertyrate Unemploymentrate i.division#c.by   , cluster(mom_birth_state)

matrix V= e(V)
matrix a = V[1..9,1..9]
svmat a

global var1=a1[1]
gen sd1=sqrt($var1)
global var2=a2[2]
gen sd2=sqrt($var2)
global var3=a3[3]
gen sd3=sqrt($var3)
global var4=a4[4]
gen sd4=sqrt($var4)
global var5=a5[5]
gen sd5=sqrt($var5)
global var6=a6[6]
gen sd6=sqrt($var6)
global var7=a7[7]
gen sd7=sqrt($var7)
global var8=a8[8]
gen sd8=sqrt($var8)
global var9=a9[9]
gen sd9=sqrt($var9)

gen lower1=_b[plus4]-(1.96*sd5)
gen upper1=_b[plus4]+(1.96*sd5)

gen order=4

gen value=_b[plus4]

keep if _n==1

keep lower1 upper1 order value


tempfile conf5

save "`conf5'"


*6


use $data/estimation_sample_blacks, clear

gen plus0=0
replace plus0=1 if index==0
gen plus1=0
replace plus1=1 if index==1
gen plus2=0
replace plus2=1 if index==2
gen plus3=0
replace plus3=1 if index==3
gen plus4=0
replace plus4=1 if index>=4


gen minus1=0
replace minus1=1 if index==-1
gen minus2=0
replace minus2=1 if index==-2
gen minus3=0
replace minus3=1 if index==-3
gen minus4=0
replace minus4=1 if index==-4
gen minus5=0
replace minus5=1 if index<=-5
ivregress 2sls newbw2500 plus0 plus1 plus2 plus3 plus4   minus2 minus3 minus4 minus5 i.year (elig00=simu00) i.birth_month  i.by i.age_cat  i.mom_birth_state   i.tbo i.male   Exitexam Perstudentexpenditure Studentteacherratio Povertyrate Unemploymentrate i.division#c.by   , cluster(mom_birth_state)

matrix V= e(V)
matrix a = V[1..9,1..9]
svmat a

global var1=a1[1]
gen sd1=sqrt($var1)
global var2=a2[2]
gen sd2=sqrt($var2)
global var3=a3[3]
gen sd3=sqrt($var3)
global var4=a4[4]
gen sd4=sqrt($var4)
global var5=a5[5]
gen sd5=sqrt($var5)
global var6=a6[6]
gen sd6=sqrt($var6)
global var7=a7[7]
gen sd7=sqrt($var7)
global var8=a8[8]
gen sd8=sqrt($var8)
global var9=a9[9]
gen sd9=sqrt($var9)

gen lower1=_b[minus2]-(1.96*sd6)
gen upper1=_b[minus2]+(1.96*sd6)

gen order=-2

gen value=_b[minus2]

keep if _n==1

keep lower1 upper1 order value


tempfile conf6

save "`conf6'"


*7


use $data/estimation_sample_blacks, clear

gen plus0=0
replace plus0=1 if index==0
gen plus1=0
replace plus1=1 if index==1
gen plus2=0
replace plus2=1 if index==2
gen plus3=0
replace plus3=1 if index==3
gen plus4=0
replace plus4=1 if index>=4


gen minus1=0
replace minus1=1 if index==-1
gen minus2=0
replace minus2=1 if index==-2
gen minus3=0
replace minus3=1 if index==-3
gen minus4=0
replace minus4=1 if index==-4
gen minus5=0
replace minus5=1 if index<=-5
ivregress 2sls newbw2500 plus0 plus1 plus2 plus3 plus4   minus2 minus3 minus4 minus5 i.year (elig00=simu00) i.birth_month  i.by i.age_cat  i.mom_birth_state   i.tbo i.male   Exitexam Perstudentexpenditure Studentteacherratio Povertyrate Unemploymentrate i.division#c.by   , cluster(mom_birth_state)

matrix V= e(V)
matrix a = V[1..9,1..9]
svmat a

global var1=a1[1]
gen sd1=sqrt($var1)
global var2=a2[2]
gen sd2=sqrt($var2)
global var3=a3[3]
gen sd3=sqrt($var3)
global var4=a4[4]
gen sd4=sqrt($var4)
global var5=a5[5]
gen sd5=sqrt($var5)
global var6=a6[6]
gen sd6=sqrt($var6)
global var7=a7[7]
gen sd7=sqrt($var7)
global var8=a8[8]
gen sd8=sqrt($var8)
global var9=a9[9]
gen sd9=sqrt($var9)

gen lower1=_b[minus3]-(1.96*sd7)
gen upper1=_b[minus3]+(1.96*sd7)

gen order=-3

gen value=_b[minus3]

keep if _n==1

keep lower1 upper1 order value


tempfile conf7

save "`conf7'"


*8


use $data/estimation_sample_blacks, clear

gen plus0=0
replace plus0=1 if index==0
gen plus1=0
replace plus1=1 if index==1
gen plus2=0
replace plus2=1 if index==2
gen plus3=0
replace plus3=1 if index==3
gen plus4=0
replace plus4=1 if index>=4


gen minus1=0
replace minus1=1 if index==-1
gen minus2=0
replace minus2=1 if index==-2
gen minus3=0
replace minus3=1 if index==-3
gen minus4=0
replace minus4=1 if index==-4
gen minus5=0
replace minus5=1 if index<=-5
ivregress 2sls newbw2500 plus0 plus1 plus2 plus3 plus4   minus2 minus3 minus4 minus5 i.year (elig00=simu00) i.birth_month  i.by i.age_cat  i.mom_birth_state   i.tbo i.male   Exitexam Perstudentexpenditure Studentteacherratio Povertyrate Unemploymentrate i.division#c.by   , cluster(mom_birth_state)

matrix V= e(V)
matrix a = V[1..9,1..9]
svmat a

global var1=a1[1]
gen sd1=sqrt($var1)
global var2=a2[2]
gen sd2=sqrt($var2)
global var3=a3[3]
gen sd3=sqrt($var3)
global var4=a4[4]
gen sd4=sqrt($var4)
global var5=a5[5]
gen sd5=sqrt($var5)
global var6=a6[6]
gen sd6=sqrt($var6)
global var7=a7[7]
gen sd7=sqrt($var7)
global var8=a8[8]
gen sd8=sqrt($var8)
global var9=a9[9]
gen sd9=sqrt($var9)

gen lower1=_b[minus4]-(1.96*sd8)
gen upper1=_b[minus4]+(1.96*sd8)

gen order=-4

gen value=_b[minus4]

keep if _n==1

keep lower1 upper1 order value


tempfile conf8

save "`conf8'"


*9


use $data/estimation_sample_blacks, clear

gen plus0=0
replace plus0=1 if index==0
gen plus1=0
replace plus1=1 if index==1
gen plus2=0
replace plus2=1 if index==2
gen plus3=0
replace plus3=1 if index==3
gen plus4=0
replace plus4=1 if index>=4


gen minus1=0
replace minus1=1 if index==-1
gen minus2=0
replace minus2=1 if index==-2
gen minus3=0
replace minus3=1 if index==-3
gen minus4=0
replace minus4=1 if index==-4
gen minus5=0
replace minus5=1 if index<=-5
ivregress 2sls newbw2500 plus0 plus1 plus2 plus3 plus4   minus2 minus3 minus4 minus5 i.year (elig00=simu00) i.birth_month  i.by i.age_cat  i.mom_birth_state   i.tbo i.male   Exitexam Perstudentexpenditure Studentteacherratio Povertyrate Unemploymentrate i.division#c.by   , cluster(mom_birth_state)

matrix V= e(V)
matrix a = V[1..9,1..9]
svmat a

global var1=a1[1]
gen sd1=sqrt($var1)
global var2=a2[2]
gen sd2=sqrt($var2)
global var3=a3[3]
gen sd3=sqrt($var3)
global var4=a4[4]
gen sd4=sqrt($var4)
global var5=a5[5]
gen sd5=sqrt($var5)
global var6=a6[6]
gen sd6=sqrt($var6)
global var7=a7[7]
gen sd7=sqrt($var7)
global var8=a8[8]
gen sd8=sqrt($var8)
global var9=a9[9]
gen sd9=sqrt($var9)

gen lower1=_b[minus5]-(1.96*sd9)
gen upper1=_b[minus5]+(1.96*sd9)

gen order=-5

gen value=_b[minus5]

keep if _n==1

keep lower1 upper1 order value


tempfile conf9

save "`conf9'"



*10


use $data/estimation_sample_blacks, clear

gen plus0=0
replace plus0=1 if index==0
gen plus1=0
replace plus1=1 if index==1
gen plus2=0
replace plus2=1 if index==2
gen plus3=0
replace plus3=1 if index==3
gen plus4=0
replace plus4=1 if index>=4


gen minus1=0
replace minus1=1 if index==-1
gen minus2=0
replace minus2=1 if index==-2
gen minus3=0
replace minus3=1 if index==-3
gen minus4=0
replace minus4=1 if index==-4
gen minus5=0
replace minus5=1 if index<=-5
ivregress 2sls newbw2500 plus0 plus1 plus2 plus3 plus4   minus2 minus3 minus4 minus5 i.year (elig00=simu00) i.birth_month  i.by i.age_cat  i.mom_birth_state   i.tbo i.male   Exitexam Perstudentexpenditure Studentteacherratio Povertyrate Unemploymentrate i.division#c.by   , cluster(mom_birth_state)
gen lower1=0
gen upper1=0
gen order=-1


gen value=0

keep if _n==1

keep lower1 upper1 order value

tempfile conf10

save "`conf10'"

use "`conf1'"

append using "`conf2'"
append using "`conf3'"
append using "`conf4'"
append using "`conf5'"
append using "`conf6'"
append using "`conf7'"
append using "`conf8'"
append using "`conf9'"
append using "`conf10'"



twoway (rcap lower1 upper1 order, lwidth(medium) lcolor(dknavy)) (scatter value order, msize(medium) mcolor(dknavy)), yline(0, lpattern(dash) lcolor(black)) ///
xlabel(-5 "-5+" -4 -3 -2 -1 0 1 2 3 4 "4+")  ylabel( , nogrid) graphregion(fcolor(white) lcolor(none)) legend(off) ///
xtitle("Elapsed Years Relative to Curriculum Change" , height(7)) ytitle(Estimated Effect-Low Birth Weight, height(7))saving(figure_b7_panela, replace)

********************************************************************************
*Figure B7; Panel C
********************************************************************************
clear all
set matsize 10000
set maxvar 40000
set more off
global data " "
global dir " "
use $data/estimation_sample_blacks, clear

gen plus0=0
replace plus0=1 if index==0
gen plus1=0
replace plus1=1 if index==1
gen plus2=0
replace plus2=1 if index==2
gen plus3=0
replace plus3=1 if index==3
gen plus4=0
replace plus4=1 if index>=4


gen minus1=0
replace minus1=1 if index==-1
gen minus2=0
replace minus2=1 if index==-2
gen minus3=0
replace minus3=1 if index==-3
gen minus4=0
replace minus4=1 if index==-4
gen minus5=0
replace minus5=1 if index<=-5

ivregress 2sls newpretermLT37 plus0 plus1 plus2 plus3 plus4   minus2 minus3 minus4 minus5 i.year (elig00=simu00) i.birth_month  i.by i.age_cat  i.mom_birth_state   i.tbo i.male   Exitexam Perstudentexpenditure Studentteacherratio Povertyrate Unemploymentrate i.division#c.by   , cluster(mom_birth_state)

matrix V= e(V)
matrix a = V[1..9,1..9]
svmat a

global var1=a1[1]
gen sd1=sqrt($var1)
global var2=a2[2]
gen sd2=sqrt($var2)
global var3=a3[3]
gen sd3=sqrt($var3)
global var4=a4[4]
gen sd4=sqrt($var4)
global var5=a5[5]
gen sd5=sqrt($var5)
global var6=a6[6]
gen sd6=sqrt($var6)
global var7=a7[7]
gen sd7=sqrt($var7)
global var8=a8[8]
gen sd8=sqrt($var8)
global var9=a9[9]
gen sd9=sqrt($var9)

gen lower1=_b[plus0]-(1.96*sd1)
gen upper1=_b[plus0]+(1.96*sd1)

gen order=0

gen value=_b[plus0]

keep if _n==1

keep lower1 upper1 order value


tempfile conf1

save "`conf1'"


*2
use $data/estimation_sample_blacks, clear

gen plus0=0
replace plus0=1 if index==0
gen plus1=0
replace plus1=1 if index==1
gen plus2=0
replace plus2=1 if index==2
gen plus3=0
replace plus3=1 if index==3
gen plus4=0
replace plus4=1 if index>=4


gen minus1=0
replace minus1=1 if index==-1
gen minus2=0
replace minus2=1 if index==-2
gen minus3=0
replace minus3=1 if index==-3
gen minus4=0
replace minus4=1 if index==-4
gen minus5=0
replace minus5=1 if index<=-5
ivregress 2sls newpretermLT37 plus0 plus1 plus2 plus3 plus4   minus2 minus3 minus4 minus5 i.year (elig00=simu00) i.birth_month  i.by i.age_cat  i.mom_birth_state   i.tbo i.male   Exitexam Perstudentexpenditure Studentteacherratio Povertyrate Unemploymentrate i.division#c.by   , cluster(mom_birth_state)

matrix V= e(V)
matrix a = V[1..9,1..9]
svmat a

global var1=a1[1]
gen sd1=sqrt($var1)
global var2=a2[2]
gen sd2=sqrt($var2)
global var3=a3[3]
gen sd3=sqrt($var3)
global var4=a4[4]
gen sd4=sqrt($var4)
global var5=a5[5]
gen sd5=sqrt($var5)
global var6=a6[6]
gen sd6=sqrt($var6)
global var7=a7[7]
gen sd7=sqrt($var7)
global var8=a8[8]
gen sd8=sqrt($var8)
global var9=a9[9]
gen sd9=sqrt($var9)

gen lower1=_b[plus1]-(1.96*sd2)
gen upper1=_b[plus1]+(1.96*sd2)

gen order=1

gen value=_b[plus1]

keep if _n==1

keep lower1 upper1 order value

tempfile conf2

save "`conf2'"


*3
use $data/estimation_sample_blacks, clear

gen plus0=0
replace plus0=1 if index==0
gen plus1=0
replace plus1=1 if index==1
gen plus2=0
replace plus2=1 if index==2
gen plus3=0
replace plus3=1 if index==3
gen plus4=0
replace plus4=1 if index>=4


gen minus1=0
replace minus1=1 if index==-1
gen minus2=0
replace minus2=1 if index==-2
gen minus3=0
replace minus3=1 if index==-3
gen minus4=0
replace minus4=1 if index==-4
gen minus5=0
replace minus5=1 if index<=-5
ivregress 2sls newpretermLT37 plus0 plus1 plus2 plus3 plus4   minus2 minus3 minus4 minus5 i.year (elig00=simu00) i.birth_month  i.by i.age_cat  i.mom_birth_state   i.tbo i.male   Exitexam Perstudentexpenditure Studentteacherratio Povertyrate Unemploymentrate i.division#c.by   , cluster(mom_birth_state)

matrix V= e(V)
matrix a = V[1..9,1..9]
svmat a

global var1=a1[1]
gen sd1=sqrt($var1)
global var2=a2[2]
gen sd2=sqrt($var2)
global var3=a3[3]
gen sd3=sqrt($var3)
global var4=a4[4]
gen sd4=sqrt($var4)
global var5=a5[5]
gen sd5=sqrt($var5)
global var6=a6[6]
gen sd6=sqrt($var6)
global var7=a7[7]
gen sd7=sqrt($var7)
global var8=a8[8]
gen sd8=sqrt($var8)
global var9=a9[9]
gen sd9=sqrt($var9)

gen lower1=_b[plus2]-(1.96*sd3)
gen upper1=_b[plus2]+(1.96*sd3)

gen order=2

gen value=_b[plus2]

keep if _n==1

keep lower1 upper1 order value


tempfile conf3

save "`conf3'"

*4
use $data/estimation_sample_blacks, clear

gen plus0=0
replace plus0=1 if index==0
gen plus1=0
replace plus1=1 if index==1
gen plus2=0
replace plus2=1 if index==2
gen plus3=0
replace plus3=1 if index==3
gen plus4=0
replace plus4=1 if index>=4


gen minus1=0
replace minus1=1 if index==-1
gen minus2=0
replace minus2=1 if index==-2
gen minus3=0
replace minus3=1 if index==-3
gen minus4=0
replace minus4=1 if index==-4
gen minus5=0
replace minus5=1 if index<=-5
ivregress 2sls newpretermLT37 plus0 plus1 plus2 plus3 plus4   minus2 minus3 minus4 minus5 i.year (elig00=simu00) i.birth_month  i.by i.age_cat  i.mom_birth_state   i.tbo i.male   Exitexam Perstudentexpenditure Studentteacherratio Povertyrate Unemploymentrate i.division#c.by   , cluster(mom_birth_state)

matrix V= e(V)
matrix a = V[1..9,1..9]
svmat a

global var1=a1[1]
gen sd1=sqrt($var1)
global var2=a2[2]
gen sd2=sqrt($var2)
global var3=a3[3]
gen sd3=sqrt($var3)
global var4=a4[4]
gen sd4=sqrt($var4)
global var5=a5[5]
gen sd5=sqrt($var5)
global var6=a6[6]
gen sd6=sqrt($var6)
global var7=a7[7]
gen sd7=sqrt($var7)
global var8=a8[8]
gen sd8=sqrt($var8)
global var9=a9[9]
gen sd9=sqrt($var9)

gen lower1=_b[plus3]-(1.96*sd4)
gen upper1=_b[plus3]+(1.96*sd4)

gen order=3

gen value=_b[plus3]

keep if _n==1

keep lower1 upper1 order value


tempfile conf4

save "`conf4'"

*5

use $data/estimation_sample_blacks, clear

gen plus0=0
replace plus0=1 if index==0
gen plus1=0
replace plus1=1 if index==1
gen plus2=0
replace plus2=1 if index==2
gen plus3=0
replace plus3=1 if index==3
gen plus4=0
replace plus4=1 if index>=4


gen minus1=0
replace minus1=1 if index==-1
gen minus2=0
replace minus2=1 if index==-2
gen minus3=0
replace minus3=1 if index==-3
gen minus4=0
replace minus4=1 if index==-4
gen minus5=0
replace minus5=1 if index<=-5
ivregress 2sls newpretermLT37 plus0 plus1 plus2 plus3 plus4   minus2 minus3 minus4 minus5 i.year (elig00=simu00) i.birth_month  i.by i.age_cat  i.mom_birth_state   i.tbo i.male   Exitexam Perstudentexpenditure Studentteacherratio Povertyrate Unemploymentrate i.division#c.by   , cluster(mom_birth_state)

matrix V= e(V)
matrix a = V[1..9,1..9]
svmat a

global var1=a1[1]
gen sd1=sqrt($var1)
global var2=a2[2]
gen sd2=sqrt($var2)
global var3=a3[3]
gen sd3=sqrt($var3)
global var4=a4[4]
gen sd4=sqrt($var4)
global var5=a5[5]
gen sd5=sqrt($var5)
global var6=a6[6]
gen sd6=sqrt($var6)
global var7=a7[7]
gen sd7=sqrt($var7)
global var8=a8[8]
gen sd8=sqrt($var8)
global var9=a9[9]
gen sd9=sqrt($var9)

gen lower1=_b[plus4]-(1.96*sd5)
gen upper1=_b[plus4]+(1.96*sd5)

gen order=4

gen value=_b[plus4]

keep if _n==1

keep lower1 upper1 order value


tempfile conf5

save "`conf5'"


*6


use $data/estimation_sample_blacks, clear

gen plus0=0
replace plus0=1 if index==0
gen plus1=0
replace plus1=1 if index==1
gen plus2=0
replace plus2=1 if index==2
gen plus3=0
replace plus3=1 if index==3
gen plus4=0
replace plus4=1 if index>=4


gen minus1=0
replace minus1=1 if index==-1
gen minus2=0
replace minus2=1 if index==-2
gen minus3=0
replace minus3=1 if index==-3
gen minus4=0
replace minus4=1 if index==-4
gen minus5=0
replace minus5=1 if index<=-5
ivregress 2sls newpretermLT37 plus0 plus1 plus2 plus3 plus4   minus2 minus3 minus4 minus5 i.year (elig00=simu00) i.birth_month  i.by i.age_cat  i.mom_birth_state   i.tbo i.male   Exitexam Perstudentexpenditure Studentteacherratio Povertyrate Unemploymentrate i.division#c.by   , cluster(mom_birth_state)

matrix V= e(V)
matrix a = V[1..9,1..9]
svmat a

global var1=a1[1]
gen sd1=sqrt($var1)
global var2=a2[2]
gen sd2=sqrt($var2)
global var3=a3[3]
gen sd3=sqrt($var3)
global var4=a4[4]
gen sd4=sqrt($var4)
global var5=a5[5]
gen sd5=sqrt($var5)
global var6=a6[6]
gen sd6=sqrt($var6)
global var7=a7[7]
gen sd7=sqrt($var7)
global var8=a8[8]
gen sd8=sqrt($var8)
global var9=a9[9]
gen sd9=sqrt($var9)

gen lower1=_b[minus2]-(1.96*sd6)
gen upper1=_b[minus2]+(1.96*sd6)

gen order=-2

gen value=_b[minus2]

keep if _n==1

keep lower1 upper1 order value


tempfile conf6

save "`conf6'"


*7


use $data/estimation_sample_blacks, clear

gen plus0=0
replace plus0=1 if index==0
gen plus1=0
replace plus1=1 if index==1
gen plus2=0
replace plus2=1 if index==2
gen plus3=0
replace plus3=1 if index==3
gen plus4=0
replace plus4=1 if index>=4


gen minus1=0
replace minus1=1 if index==-1
gen minus2=0
replace minus2=1 if index==-2
gen minus3=0
replace minus3=1 if index==-3
gen minus4=0
replace minus4=1 if index==-4
gen minus5=0
replace minus5=1 if index<=-5
ivregress 2sls newpretermLT37 plus0 plus1 plus2 plus3 plus4   minus2 minus3 minus4 minus5 i.year (elig00=simu00) i.birth_month  i.by i.age_cat  i.mom_birth_state   i.tbo i.male   Exitexam Perstudentexpenditure Studentteacherratio Povertyrate Unemploymentrate i.division#c.by   , cluster(mom_birth_state)

matrix V= e(V)
matrix a = V[1..9,1..9]
svmat a

global var1=a1[1]
gen sd1=sqrt($var1)
global var2=a2[2]
gen sd2=sqrt($var2)
global var3=a3[3]
gen sd3=sqrt($var3)
global var4=a4[4]
gen sd4=sqrt($var4)
global var5=a5[5]
gen sd5=sqrt($var5)
global var6=a6[6]
gen sd6=sqrt($var6)
global var7=a7[7]
gen sd7=sqrt($var7)
global var8=a8[8]
gen sd8=sqrt($var8)
global var9=a9[9]
gen sd9=sqrt($var9)

gen lower1=_b[minus3]-(1.96*sd7)
gen upper1=_b[minus3]+(1.96*sd7)

gen order=-3

gen value=_b[minus3]

keep if _n==1

keep lower1 upper1 order value


tempfile conf7

save "`conf7'"


*8


use $data/estimation_sample_blacks, clear

gen plus0=0
replace plus0=1 if index==0
gen plus1=0
replace plus1=1 if index==1
gen plus2=0
replace plus2=1 if index==2
gen plus3=0
replace plus3=1 if index==3
gen plus4=0
replace plus4=1 if index>=4


gen minus1=0
replace minus1=1 if index==-1
gen minus2=0
replace minus2=1 if index==-2
gen minus3=0
replace minus3=1 if index==-3
gen minus4=0
replace minus4=1 if index==-4
gen minus5=0
replace minus5=1 if index<=-5
ivregress 2sls newpretermLT37 plus0 plus1 plus2 plus3 plus4   minus2 minus3 minus4 minus5 i.year (elig00=simu00) i.birth_month  i.by i.age_cat  i.mom_birth_state   i.tbo i.male   Exitexam Perstudentexpenditure Studentteacherratio Povertyrate Unemploymentrate i.division#c.by   , cluster(mom_birth_state)

matrix V= e(V)
matrix a = V[1..9,1..9]
svmat a

global var1=a1[1]
gen sd1=sqrt($var1)
global var2=a2[2]
gen sd2=sqrt($var2)
global var3=a3[3]
gen sd3=sqrt($var3)
global var4=a4[4]
gen sd4=sqrt($var4)
global var5=a5[5]
gen sd5=sqrt($var5)
global var6=a6[6]
gen sd6=sqrt($var6)
global var7=a7[7]
gen sd7=sqrt($var7)
global var8=a8[8]
gen sd8=sqrt($var8)
global var9=a9[9]
gen sd9=sqrt($var9)

gen lower1=_b[minus4]-(1.96*sd8)
gen upper1=_b[minus4]+(1.96*sd8)

gen order=-4

gen value=_b[minus4]

keep if _n==1

keep lower1 upper1 order value


tempfile conf8

save "`conf8'"


*9


use $data/estimation_sample_blacks, clear

gen plus0=0
replace plus0=1 if index==0
gen plus1=0
replace plus1=1 if index==1
gen plus2=0
replace plus2=1 if index==2
gen plus3=0
replace plus3=1 if index==3
gen plus4=0
replace plus4=1 if index>=4


gen minus1=0
replace minus1=1 if index==-1
gen minus2=0
replace minus2=1 if index==-2
gen minus3=0
replace minus3=1 if index==-3
gen minus4=0
replace minus4=1 if index==-4
gen minus5=0
replace minus5=1 if index<=-5
ivregress 2sls newpretermLT37 plus0 plus1 plus2 plus3 plus4   minus2 minus3 minus4 minus5 i.year (elig00=simu00) i.birth_month  i.by i.age_cat  i.mom_birth_state   i.tbo i.male   Exitexam Perstudentexpenditure Studentteacherratio Povertyrate Unemploymentrate i.division#c.by   , cluster(mom_birth_state)

matrix V= e(V)
matrix a = V[1..9,1..9]
svmat a

global var1=a1[1]
gen sd1=sqrt($var1)
global var2=a2[2]
gen sd2=sqrt($var2)
global var3=a3[3]
gen sd3=sqrt($var3)
global var4=a4[4]
gen sd4=sqrt($var4)
global var5=a5[5]
gen sd5=sqrt($var5)
global var6=a6[6]
gen sd6=sqrt($var6)
global var7=a7[7]
gen sd7=sqrt($var7)
global var8=a8[8]
gen sd8=sqrt($var8)
global var9=a9[9]
gen sd9=sqrt($var9)

gen lower1=_b[minus5]-(1.96*sd9)
gen upper1=_b[minus5]+(1.96*sd9)

gen order=-5

gen value=_b[minus5]

keep if _n==1

keep lower1 upper1 order value


tempfile conf9

save "`conf9'"



*10


use $data/estimation_sample_blacks, clear

gen plus0=0
replace plus0=1 if index==0
gen plus1=0
replace plus1=1 if index==1
gen plus2=0
replace plus2=1 if index==2
gen plus3=0
replace plus3=1 if index==3
gen plus4=0
replace plus4=1 if index>=4


gen minus1=0
replace minus1=1 if index==-1
gen minus2=0
replace minus2=1 if index==-2
gen minus3=0
replace minus3=1 if index==-3
gen minus4=0
replace minus4=1 if index==-4
gen minus5=0
replace minus5=1 if index<=-5
ivregress 2sls newpretermLT37 plus0 plus1 plus2 plus3 plus4   minus2 minus3 minus4 minus5 i.year (elig00=simu00) i.birth_month  i.by i.age_cat  i.mom_birth_state   i.tbo i.male   Exitexam Perstudentexpenditure Studentteacherratio Povertyrate Unemploymentrate i.division#c.by   , cluster(mom_birth_state)
gen lower1=0
gen upper1=0
gen order=-1


gen value=0

keep if _n==1

keep lower1 upper1 order value

tempfile conf10

save "`conf10'"

use "`conf1'"

append using "`conf2'"
append using "`conf3'"
append using "`conf4'"
append using "`conf5'"
append using "`conf6'"
append using "`conf7'"
append using "`conf8'"
append using "`conf9'"
append using "`conf10'"



twoway (rcap lower1 upper1 order, lwidth(medium) lcolor(dknavy)) (scatter value order, msize(medium) mcolor(dknavy)), yline(0, lpattern(dash) lcolor(black)) ///
xlabel(-5 "-5+" -4 -3 -2 -1 0 1 2 3 4 "4+")  ylabel( , nogrid) graphregion(fcolor(white) lcolor(none)) legend(off) ///
xtitle("Elapsed Years Relative to Curriculum Change" , height(7)) ytitle(Estimated Effect-Prematurity, height(7))saving(figure_b7_panelc, replace)


********************************************************************************
*Figure B7; Panel B
********************************************************************************
clear all
set matsize 10000
set maxvar 40000
set more off
global data " "
global dir " "
use $data/estimation_sample_whites, clear

gen plus0=0
replace plus0=1 if index==0
gen plus1=0
replace plus1=1 if index==1
gen plus2=0
replace plus2=1 if index==2
gen plus3=0
replace plus3=1 if index==3
gen plus4=0
replace plus4=1 if index>=4


gen minus1=0
replace minus1=1 if index==-1
gen minus2=0
replace minus2=1 if index==-2
gen minus3=0
replace minus3=1 if index==-3
gen minus4=0
replace minus4=1 if index==-4
gen minus5=0
replace minus5=1 if index<=-5
ivregress 2sls         newbw2500 plus0 plus1 plus2 plus3 plus4   minus2 minus3 minus4 minus5 (elig00=simu00) i.year i.birth_month  i.by i.age_cat  i.mom_birth_state   i.tbo i.male   Exitexam Perstudentexpenditure Studentteacherratio Povertyrate Unemploymentrate i.division#c.by   , cluster(mom_birth_state)
matrix V= e(V)
matrix a = V[1..9,1..9]
svmat a

global var1=a1[1]
gen sd1=sqrt($var1)
global var2=a2[2]
gen sd2=sqrt($var2)
global var3=a3[3]
gen sd3=sqrt($var3)
global var4=a4[4]
gen sd4=sqrt($var4)
global var5=a5[5]
gen sd5=sqrt($var5)
global var6=a6[6]
gen sd6=sqrt($var6)
global var7=a7[7]
gen sd7=sqrt($var7)
global var8=a8[8]
gen sd8=sqrt($var8)
global var9=a9[9]
gen sd9=sqrt($var9)

gen lower1=_b[plus0]-(1.96*sd1)
gen upper1=_b[plus0]+(1.96*sd1)

gen order=0

gen value=_b[plus0]

keep if _n==1

keep lower1 upper1 order value


tempfile conf1

save "`conf1'"


*2
use $data/estimation_sample_whites, clear

gen plus0=0
replace plus0=1 if index==0
gen plus1=0
replace plus1=1 if index==1
gen plus2=0
replace plus2=1 if index==2
gen plus3=0
replace plus3=1 if index==3
gen plus4=0
replace plus4=1 if index>=4


gen minus1=0
replace minus1=1 if index==-1
gen minus2=0
replace minus2=1 if index==-2
gen minus3=0
replace minus3=1 if index==-3
gen minus4=0
replace minus4=1 if index==-4
gen minus5=0
replace minus5=1 if index<=-5
ivregress 2sls newbw2500 plus0 plus1 plus2 plus3 plus4   minus2 minus3 minus4 minus5 i.year (elig00=simu00) i.birth_month  i.by i.age_cat  i.mom_birth_state   i.tbo i.male   Exitexam Perstudentexpenditure Studentteacherratio Povertyrate Unemploymentrate i.division#c.by   , cluster(mom_birth_state)

matrix V= e(V)
matrix a = V[1..9,1..9]
svmat a

global var1=a1[1]
gen sd1=sqrt($var1)
global var2=a2[2]
gen sd2=sqrt($var2)
global var3=a3[3]
gen sd3=sqrt($var3)
global var4=a4[4]
gen sd4=sqrt($var4)
global var5=a5[5]
gen sd5=sqrt($var5)
global var6=a6[6]
gen sd6=sqrt($var6)
global var7=a7[7]
gen sd7=sqrt($var7)
global var8=a8[8]
gen sd8=sqrt($var8)
global var9=a9[9]
gen sd9=sqrt($var9)

gen lower1=_b[plus1]-(1.96*sd2)
gen upper1=_b[plus1]+(1.96*sd2)

gen order=1

gen value=_b[plus1]

keep if _n==1

keep lower1 upper1 order value

tempfile conf2

save "`conf2'"


*3
use $data/estimation_sample_whites, clear

gen plus0=0
replace plus0=1 if index==0
gen plus1=0
replace plus1=1 if index==1
gen plus2=0
replace plus2=1 if index==2
gen plus3=0
replace plus3=1 if index==3
gen plus4=0
replace plus4=1 if index>=4


gen minus1=0
replace minus1=1 if index==-1
gen minus2=0
replace minus2=1 if index==-2
gen minus3=0
replace minus3=1 if index==-3
gen minus4=0
replace minus4=1 if index==-4
gen minus5=0
replace minus5=1 if index<=-5
ivregress 2sls newbw2500 plus0 plus1 plus2 plus3 plus4   minus2 minus3 minus4 minus5 i.year (elig00=simu00) i.birth_month  i.by i.age_cat  i.mom_birth_state   i.tbo i.male   Exitexam Perstudentexpenditure Studentteacherratio Povertyrate Unemploymentrate i.division#c.by   , cluster(mom_birth_state)

matrix V= e(V)
matrix a = V[1..9,1..9]
svmat a

global var1=a1[1]
gen sd1=sqrt($var1)
global var2=a2[2]
gen sd2=sqrt($var2)
global var3=a3[3]
gen sd3=sqrt($var3)
global var4=a4[4]
gen sd4=sqrt($var4)
global var5=a5[5]
gen sd5=sqrt($var5)
global var6=a6[6]
gen sd6=sqrt($var6)
global var7=a7[7]
gen sd7=sqrt($var7)
global var8=a8[8]
gen sd8=sqrt($var8)
global var9=a9[9]
gen sd9=sqrt($var9)

gen lower1=_b[plus2]-(1.96*sd3)
gen upper1=_b[plus2]+(1.96*sd3)

gen order=2

gen value=_b[plus2]

keep if _n==1

keep lower1 upper1 order value


tempfile conf3

save "`conf3'"

*4
use $data/estimation_sample_whites, clear

gen plus0=0
replace plus0=1 if index==0
gen plus1=0
replace plus1=1 if index==1
gen plus2=0
replace plus2=1 if index==2
gen plus3=0
replace plus3=1 if index==3
gen plus4=0
replace plus4=1 if index>=4


gen minus1=0
replace minus1=1 if index==-1
gen minus2=0
replace minus2=1 if index==-2
gen minus3=0
replace minus3=1 if index==-3
gen minus4=0
replace minus4=1 if index==-4
gen minus5=0
replace minus5=1 if index<=-5
ivregress 2sls newbw2500 plus0 plus1 plus2 plus3 plus4   minus2 minus3 minus4 minus5 i.year (elig00=simu00) i.birth_month  i.by i.age_cat  i.mom_birth_state   i.tbo i.male   Exitexam Perstudentexpenditure Studentteacherratio Povertyrate Unemploymentrate i.division#c.by   , cluster(mom_birth_state)

matrix V= e(V)
matrix a = V[1..9,1..9]
svmat a

global var1=a1[1]
gen sd1=sqrt($var1)
global var2=a2[2]
gen sd2=sqrt($var2)
global var3=a3[3]
gen sd3=sqrt($var3)
global var4=a4[4]
gen sd4=sqrt($var4)
global var5=a5[5]
gen sd5=sqrt($var5)
global var6=a6[6]
gen sd6=sqrt($var6)
global var7=a7[7]
gen sd7=sqrt($var7)
global var8=a8[8]
gen sd8=sqrt($var8)
global var9=a9[9]
gen sd9=sqrt($var9)

gen lower1=_b[plus3]-(1.96*sd4)
gen upper1=_b[plus3]+(1.96*sd4)

gen order=3

gen value=_b[plus3]

keep if _n==1

keep lower1 upper1 order value


tempfile conf4

save "`conf4'"

*5

use $data/estimation_sample_whites, clear

gen plus0=0
replace plus0=1 if index==0
gen plus1=0
replace plus1=1 if index==1
gen plus2=0
replace plus2=1 if index==2
gen plus3=0
replace plus3=1 if index==3
gen plus4=0
replace plus4=1 if index>=4


gen minus1=0
replace minus1=1 if index==-1
gen minus2=0
replace minus2=1 if index==-2
gen minus3=0
replace minus3=1 if index==-3
gen minus4=0
replace minus4=1 if index==-4
gen minus5=0
replace minus5=1 if index<=-5
ivregress 2sls newbw2500 plus0 plus1 plus2 plus3 plus4   minus2 minus3 minus4 minus5 i.year (elig00=simu00) i.birth_month  i.by i.age_cat  i.mom_birth_state   i.tbo i.male   Exitexam Perstudentexpenditure Studentteacherratio Povertyrate Unemploymentrate i.division#c.by   , cluster(mom_birth_state)

matrix V= e(V)
matrix a = V[1..9,1..9]
svmat a

global var1=a1[1]
gen sd1=sqrt($var1)
global var2=a2[2]
gen sd2=sqrt($var2)
global var3=a3[3]
gen sd3=sqrt($var3)
global var4=a4[4]
gen sd4=sqrt($var4)
global var5=a5[5]
gen sd5=sqrt($var5)
global var6=a6[6]
gen sd6=sqrt($var6)
global var7=a7[7]
gen sd7=sqrt($var7)
global var8=a8[8]
gen sd8=sqrt($var8)
global var9=a9[9]
gen sd9=sqrt($var9)

gen lower1=_b[plus4]-(1.96*sd5)
gen upper1=_b[plus4]+(1.96*sd5)

gen order=4

gen value=_b[plus4]

keep if _n==1

keep lower1 upper1 order value


tempfile conf5

save "`conf5'"


*6


use $data/estimation_sample_whites, clear

gen plus0=0
replace plus0=1 if index==0
gen plus1=0
replace plus1=1 if index==1
gen plus2=0
replace plus2=1 if index==2
gen plus3=0
replace plus3=1 if index==3
gen plus4=0
replace plus4=1 if index>=4


gen minus1=0
replace minus1=1 if index==-1
gen minus2=0
replace minus2=1 if index==-2
gen minus3=0
replace minus3=1 if index==-3
gen minus4=0
replace minus4=1 if index==-4
gen minus5=0
replace minus5=1 if index<=-5
ivregress 2sls newbw2500 plus0 plus1 plus2 plus3 plus4   minus2 minus3 minus4 minus5 i.year (elig00=simu00) i.birth_month  i.by i.age_cat  i.mom_birth_state   i.tbo i.male   Exitexam Perstudentexpenditure Studentteacherratio Povertyrate Unemploymentrate i.division#c.by   , cluster(mom_birth_state)

matrix V= e(V)
matrix a = V[1..9,1..9]
svmat a

global var1=a1[1]
gen sd1=sqrt($var1)
global var2=a2[2]
gen sd2=sqrt($var2)
global var3=a3[3]
gen sd3=sqrt($var3)
global var4=a4[4]
gen sd4=sqrt($var4)
global var5=a5[5]
gen sd5=sqrt($var5)
global var6=a6[6]
gen sd6=sqrt($var6)
global var7=a7[7]
gen sd7=sqrt($var7)
global var8=a8[8]
gen sd8=sqrt($var8)
global var9=a9[9]
gen sd9=sqrt($var9)

gen lower1=_b[minus2]-(1.96*sd6)
gen upper1=_b[minus2]+(1.96*sd6)

gen order=-2

gen value=_b[minus2]

keep if _n==1

keep lower1 upper1 order value


tempfile conf6

save "`conf6'"


*7


use $data/estimation_sample_whites, clear

gen plus0=0
replace plus0=1 if index==0
gen plus1=0
replace plus1=1 if index==1
gen plus2=0
replace plus2=1 if index==2
gen plus3=0
replace plus3=1 if index==3
gen plus4=0
replace plus4=1 if index>=4


gen minus1=0
replace minus1=1 if index==-1
gen minus2=0
replace minus2=1 if index==-2
gen minus3=0
replace minus3=1 if index==-3
gen minus4=0
replace minus4=1 if index==-4
gen minus5=0
replace minus5=1 if index<=-5
ivregress 2sls newbw2500 plus0 plus1 plus2 plus3 plus4   minus2 minus3 minus4 minus5 i.year (elig00=simu00) i.birth_month  i.by i.age_cat  i.mom_birth_state   i.tbo i.male   Exitexam Perstudentexpenditure Studentteacherratio Povertyrate Unemploymentrate i.division#c.by   , cluster(mom_birth_state)

matrix V= e(V)
matrix a = V[1..9,1..9]
svmat a

global var1=a1[1]
gen sd1=sqrt($var1)
global var2=a2[2]
gen sd2=sqrt($var2)
global var3=a3[3]
gen sd3=sqrt($var3)
global var4=a4[4]
gen sd4=sqrt($var4)
global var5=a5[5]
gen sd5=sqrt($var5)
global var6=a6[6]
gen sd6=sqrt($var6)
global var7=a7[7]
gen sd7=sqrt($var7)
global var8=a8[8]
gen sd8=sqrt($var8)
global var9=a9[9]
gen sd9=sqrt($var9)

gen lower1=_b[minus3]-(1.96*sd7)
gen upper1=_b[minus3]+(1.96*sd7)

gen order=-3

gen value=_b[minus3]

keep if _n==1

keep lower1 upper1 order value


tempfile conf7

save "`conf7'"


*8


use $data/estimation_sample_whites, clear

gen plus0=0
replace plus0=1 if index==0
gen plus1=0
replace plus1=1 if index==1
gen plus2=0
replace plus2=1 if index==2
gen plus3=0
replace plus3=1 if index==3
gen plus4=0
replace plus4=1 if index>=4


gen minus1=0
replace minus1=1 if index==-1
gen minus2=0
replace minus2=1 if index==-2
gen minus3=0
replace minus3=1 if index==-3
gen minus4=0
replace minus4=1 if index==-4
gen minus5=0
replace minus5=1 if index<=-5
ivregress 2sls newbw2500 plus0 plus1 plus2 plus3 plus4   minus2 minus3 minus4 minus5 i.year (elig00=simu00) i.birth_month  i.by i.age_cat  i.mom_birth_state   i.tbo i.male   Exitexam Perstudentexpenditure Studentteacherratio Povertyrate Unemploymentrate i.division#c.by   , cluster(mom_birth_state)

matrix V= e(V)
matrix a = V[1..9,1..9]
svmat a

global var1=a1[1]
gen sd1=sqrt($var1)
global var2=a2[2]
gen sd2=sqrt($var2)
global var3=a3[3]
gen sd3=sqrt($var3)
global var4=a4[4]
gen sd4=sqrt($var4)
global var5=a5[5]
gen sd5=sqrt($var5)
global var6=a6[6]
gen sd6=sqrt($var6)
global var7=a7[7]
gen sd7=sqrt($var7)
global var8=a8[8]
gen sd8=sqrt($var8)
global var9=a9[9]
gen sd9=sqrt($var9)

gen lower1=_b[minus4]-(1.96*sd8)
gen upper1=_b[minus4]+(1.96*sd8)

gen order=-4

gen value=_b[minus4]

keep if _n==1

keep lower1 upper1 order value


tempfile conf8

save "`conf8'"


*9


use $data/estimation_sample_whites, clear

gen plus0=0
replace plus0=1 if index==0
gen plus1=0
replace plus1=1 if index==1
gen plus2=0
replace plus2=1 if index==2
gen plus3=0
replace plus3=1 if index==3
gen plus4=0
replace plus4=1 if index>=4


gen minus1=0
replace minus1=1 if index==-1
gen minus2=0
replace minus2=1 if index==-2
gen minus3=0
replace minus3=1 if index==-3
gen minus4=0
replace minus4=1 if index==-4
gen minus5=0
replace minus5=1 if index<=-5
ivregress 2sls newbw2500 plus0 plus1 plus2 plus3 plus4   minus2 minus3 minus4 minus5 i.year (elig00=simu00) i.birth_month  i.by i.age_cat  i.mom_birth_state   i.tbo i.male   Exitexam Perstudentexpenditure Studentteacherratio Povertyrate Unemploymentrate i.division#c.by   , cluster(mom_birth_state)

matrix V= e(V)
matrix a = V[1..9,1..9]
svmat a

global var1=a1[1]
gen sd1=sqrt($var1)
global var2=a2[2]
gen sd2=sqrt($var2)
global var3=a3[3]
gen sd3=sqrt($var3)
global var4=a4[4]
gen sd4=sqrt($var4)
global var5=a5[5]
gen sd5=sqrt($var5)
global var6=a6[6]
gen sd6=sqrt($var6)
global var7=a7[7]
gen sd7=sqrt($var7)
global var8=a8[8]
gen sd8=sqrt($var8)
global var9=a9[9]
gen sd9=sqrt($var9)

gen lower1=_b[minus5]-(1.96*sd9)
gen upper1=_b[minus5]+(1.96*sd9)

gen order=-5

gen value=_b[minus5]

keep if _n==1

keep lower1 upper1 order value


tempfile conf9

save "`conf9'"



*10


use $data/estimation_sample_whites, clear

gen plus0=0
replace plus0=1 if index==0
gen plus1=0
replace plus1=1 if index==1
gen plus2=0
replace plus2=1 if index==2
gen plus3=0
replace plus3=1 if index==3
gen plus4=0
replace plus4=1 if index>=4


gen minus1=0
replace minus1=1 if index==-1
gen minus2=0
replace minus2=1 if index==-2
gen minus3=0
replace minus3=1 if index==-3
gen minus4=0
replace minus4=1 if index==-4
gen minus5=0
replace minus5=1 if index<=-5
ivregress 2sls newbw2500 plus0 plus1 plus2 plus3 plus4   minus2 minus3 minus4 minus5 i.year (elig00=simu00) i.birth_month  i.by i.age_cat  i.mom_birth_state   i.tbo i.male   Exitexam Perstudentexpenditure Studentteacherratio Povertyrate Unemploymentrate i.division#c.by   , cluster(mom_birth_state)
gen lower1=0
gen upper1=0
gen order=-1


gen value=0

keep if _n==1

keep lower1 upper1 order value

tempfile conf10

save "`conf10'"

use "`conf1'"

append using "`conf2'"
append using "`conf3'"
append using "`conf4'"
append using "`conf5'"
append using "`conf6'"
append using "`conf7'"
append using "`conf8'"
append using "`conf9'"
append using "`conf10'"



twoway (rcap lower1 upper1 order, lwidth(medium) lcolor(dknavy)) (scatter value order, msize(medium) mcolor(dknavy)), yline(0, lpattern(dash) lcolor(black)) ///
xlabel(-5 "-5+" -4 -3 -2 -1 0 1 2 3 4 "4+")  ylabel( , nogrid) graphregion(fcolor(white) lcolor(none)) legend(off) ///
xtitle("Elapsed Years Relative to Curriculum Change" , height(7)) ytitle(Estimated Effect-Low Birth Weight, height(7))saving(figure_b7_panelb, replace)

********************************************************************************
*Figure B7; Panel D
********************************************************************************
clear all
set matsize 10000
set maxvar 40000
set more off
global data " "
global dir " "
use $data/estimation_sample_whites, clear

gen plus0=0
replace plus0=1 if index==0
gen plus1=0
replace plus1=1 if index==1
gen plus2=0
replace plus2=1 if index==2
gen plus3=0
replace plus3=1 if index==3
gen plus4=0
replace plus4=1 if index>=4


gen minus1=0
replace minus1=1 if index==-1
gen minus2=0
replace minus2=1 if index==-2
gen minus3=0
replace minus3=1 if index==-3
gen minus4=0
replace minus4=1 if index==-4
gen minus5=0
replace minus5=1 if index<=-5

ivregress 2sls newpretermLT37 plus0 plus1 plus2 plus3 plus4   minus2 minus3 minus4 minus5 i.year (elig00=simu00) i.birth_month  i.by i.age_cat  i.mom_birth_state   i.tbo i.male   Exitexam Perstudentexpenditure Studentteacherratio Povertyrate Unemploymentrate i.division#c.by   , cluster(mom_birth_state)

matrix V= e(V)
matrix a = V[1..9,1..9]
svmat a

global var1=a1[1]
gen sd1=sqrt($var1)
global var2=a2[2]
gen sd2=sqrt($var2)
global var3=a3[3]
gen sd3=sqrt($var3)
global var4=a4[4]
gen sd4=sqrt($var4)
global var5=a5[5]
gen sd5=sqrt($var5)
global var6=a6[6]
gen sd6=sqrt($var6)
global var7=a7[7]
gen sd7=sqrt($var7)
global var8=a8[8]
gen sd8=sqrt($var8)
global var9=a9[9]
gen sd9=sqrt($var9)

gen lower1=_b[plus0]-(1.96*sd1)
gen upper1=_b[plus0]+(1.96*sd1)

gen order=0

gen value=_b[plus0]

keep if _n==1

keep lower1 upper1 order value


tempfile conf1

save "`conf1'"


*2
use $data/estimation_sample_whites, clear

gen plus0=0
replace plus0=1 if index==0
gen plus1=0
replace plus1=1 if index==1
gen plus2=0
replace plus2=1 if index==2
gen plus3=0
replace plus3=1 if index==3
gen plus4=0
replace plus4=1 if index>=4


gen minus1=0
replace minus1=1 if index==-1
gen minus2=0
replace minus2=1 if index==-2
gen minus3=0
replace minus3=1 if index==-3
gen minus4=0
replace minus4=1 if index==-4
gen minus5=0
replace minus5=1 if index<=-5
ivregress 2sls newpretermLT37 plus0 plus1 plus2 plus3 plus4   minus2 minus3 minus4 minus5 i.year (elig00=simu00) i.birth_month  i.by i.age_cat  i.mom_birth_state   i.tbo i.male   Exitexam Perstudentexpenditure Studentteacherratio Povertyrate Unemploymentrate i.division#c.by   , cluster(mom_birth_state)

matrix V= e(V)
matrix a = V[1..9,1..9]
svmat a

global var1=a1[1]
gen sd1=sqrt($var1)
global var2=a2[2]
gen sd2=sqrt($var2)
global var3=a3[3]
gen sd3=sqrt($var3)
global var4=a4[4]
gen sd4=sqrt($var4)
global var5=a5[5]
gen sd5=sqrt($var5)
global var6=a6[6]
gen sd6=sqrt($var6)
global var7=a7[7]
gen sd7=sqrt($var7)
global var8=a8[8]
gen sd8=sqrt($var8)
global var9=a9[9]
gen sd9=sqrt($var9)

gen lower1=_b[plus1]-(1.96*sd2)
gen upper1=_b[plus1]+(1.96*sd2)

gen order=1

gen value=_b[plus1]

keep if _n==1

keep lower1 upper1 order value

tempfile conf2

save "`conf2'"


*3
use $data/estimation_sample_whites, clear

gen plus0=0
replace plus0=1 if index==0
gen plus1=0
replace plus1=1 if index==1
gen plus2=0
replace plus2=1 if index==2
gen plus3=0
replace plus3=1 if index==3
gen plus4=0
replace plus4=1 if index>=4


gen minus1=0
replace minus1=1 if index==-1
gen minus2=0
replace minus2=1 if index==-2
gen minus3=0
replace minus3=1 if index==-3
gen minus4=0
replace minus4=1 if index==-4
gen minus5=0
replace minus5=1 if index<=-5
ivregress 2sls newpretermLT37 plus0 plus1 plus2 plus3 plus4   minus2 minus3 minus4 minus5 i.year (elig00=simu00) i.birth_month  i.by i.age_cat  i.mom_birth_state   i.tbo i.male   Exitexam Perstudentexpenditure Studentteacherratio Povertyrate Unemploymentrate i.division#c.by   , cluster(mom_birth_state)

matrix V= e(V)
matrix a = V[1..9,1..9]
svmat a

global var1=a1[1]
gen sd1=sqrt($var1)
global var2=a2[2]
gen sd2=sqrt($var2)
global var3=a3[3]
gen sd3=sqrt($var3)
global var4=a4[4]
gen sd4=sqrt($var4)
global var5=a5[5]
gen sd5=sqrt($var5)
global var6=a6[6]
gen sd6=sqrt($var6)
global var7=a7[7]
gen sd7=sqrt($var7)
global var8=a8[8]
gen sd8=sqrt($var8)
global var9=a9[9]
gen sd9=sqrt($var9)

gen lower1=_b[plus2]-(1.96*sd3)
gen upper1=_b[plus2]+(1.96*sd3)

gen order=2

gen value=_b[plus2]

keep if _n==1

keep lower1 upper1 order value


tempfile conf3

save "`conf3'"

*4
use $data/estimation_sample_whites, clear

gen plus0=0
replace plus0=1 if index==0
gen plus1=0
replace plus1=1 if index==1
gen plus2=0
replace plus2=1 if index==2
gen plus3=0
replace plus3=1 if index==3
gen plus4=0
replace plus4=1 if index>=4


gen minus1=0
replace minus1=1 if index==-1
gen minus2=0
replace minus2=1 if index==-2
gen minus3=0
replace minus3=1 if index==-3
gen minus4=0
replace minus4=1 if index==-4
gen minus5=0
replace minus5=1 if index<=-5
ivregress 2sls newpretermLT37 plus0 plus1 plus2 plus3 plus4   minus2 minus3 minus4 minus5 i.year (elig00=simu00) i.birth_month  i.by i.age_cat  i.mom_birth_state   i.tbo i.male   Exitexam Perstudentexpenditure Studentteacherratio Povertyrate Unemploymentrate i.division#c.by   , cluster(mom_birth_state)

matrix V= e(V)
matrix a = V[1..9,1..9]
svmat a

global var1=a1[1]
gen sd1=sqrt($var1)
global var2=a2[2]
gen sd2=sqrt($var2)
global var3=a3[3]
gen sd3=sqrt($var3)
global var4=a4[4]
gen sd4=sqrt($var4)
global var5=a5[5]
gen sd5=sqrt($var5)
global var6=a6[6]
gen sd6=sqrt($var6)
global var7=a7[7]
gen sd7=sqrt($var7)
global var8=a8[8]
gen sd8=sqrt($var8)
global var9=a9[9]
gen sd9=sqrt($var9)

gen lower1=_b[plus3]-(1.96*sd4)
gen upper1=_b[plus3]+(1.96*sd4)

gen order=3

gen value=_b[plus3]

keep if _n==1

keep lower1 upper1 order value


tempfile conf4

save "`conf4'"

*5

use $data/estimation_sample_whites, clear

gen plus0=0
replace plus0=1 if index==0
gen plus1=0
replace plus1=1 if index==1
gen plus2=0
replace plus2=1 if index==2
gen plus3=0
replace plus3=1 if index==3
gen plus4=0
replace plus4=1 if index>=4


gen minus1=0
replace minus1=1 if index==-1
gen minus2=0
replace minus2=1 if index==-2
gen minus3=0
replace minus3=1 if index==-3
gen minus4=0
replace minus4=1 if index==-4
gen minus5=0
replace minus5=1 if index<=-5
ivregress 2sls newpretermLT37 plus0 plus1 plus2 plus3 plus4   minus2 minus3 minus4 minus5 i.year (elig00=simu00) i.birth_month  i.by i.age_cat  i.mom_birth_state   i.tbo i.male   Exitexam Perstudentexpenditure Studentteacherratio Povertyrate Unemploymentrate i.division#c.by   , cluster(mom_birth_state)

matrix V= e(V)
matrix a = V[1..9,1..9]
svmat a

global var1=a1[1]
gen sd1=sqrt($var1)
global var2=a2[2]
gen sd2=sqrt($var2)
global var3=a3[3]
gen sd3=sqrt($var3)
global var4=a4[4]
gen sd4=sqrt($var4)
global var5=a5[5]
gen sd5=sqrt($var5)
global var6=a6[6]
gen sd6=sqrt($var6)
global var7=a7[7]
gen sd7=sqrt($var7)
global var8=a8[8]
gen sd8=sqrt($var8)
global var9=a9[9]
gen sd9=sqrt($var9)

gen lower1=_b[plus4]-(1.96*sd5)
gen upper1=_b[plus4]+(1.96*sd5)

gen order=4

gen value=_b[plus4]

keep if _n==1

keep lower1 upper1 order value


tempfile conf5

save "`conf5'"


*6


use $data/estimation_sample_whites, clear

gen plus0=0
replace plus0=1 if index==0
gen plus1=0
replace plus1=1 if index==1
gen plus2=0
replace plus2=1 if index==2
gen plus3=0
replace plus3=1 if index==3
gen plus4=0
replace plus4=1 if index>=4


gen minus1=0
replace minus1=1 if index==-1
gen minus2=0
replace minus2=1 if index==-2
gen minus3=0
replace minus3=1 if index==-3
gen minus4=0
replace minus4=1 if index==-4
gen minus5=0
replace minus5=1 if index<=-5
ivregress 2sls newpretermLT37 plus0 plus1 plus2 plus3 plus4   minus2 minus3 minus4 minus5 i.year (elig00=simu00) i.birth_month  i.by i.age_cat  i.mom_birth_state   i.tbo i.male   Exitexam Perstudentexpenditure Studentteacherratio Povertyrate Unemploymentrate i.division#c.by   , cluster(mom_birth_state)

matrix V= e(V)
matrix a = V[1..9,1..9]
svmat a

global var1=a1[1]
gen sd1=sqrt($var1)
global var2=a2[2]
gen sd2=sqrt($var2)
global var3=a3[3]
gen sd3=sqrt($var3)
global var4=a4[4]
gen sd4=sqrt($var4)
global var5=a5[5]
gen sd5=sqrt($var5)
global var6=a6[6]
gen sd6=sqrt($var6)
global var7=a7[7]
gen sd7=sqrt($var7)
global var8=a8[8]
gen sd8=sqrt($var8)
global var9=a9[9]
gen sd9=sqrt($var9)

gen lower1=_b[minus2]-(1.96*sd6)
gen upper1=_b[minus2]+(1.96*sd6)

gen order=-2

gen value=_b[minus2]

keep if _n==1

keep lower1 upper1 order value


tempfile conf6

save "`conf6'"


*7


use $data/estimation_sample_whites, clear

gen plus0=0
replace plus0=1 if index==0
gen plus1=0
replace plus1=1 if index==1
gen plus2=0
replace plus2=1 if index==2
gen plus3=0
replace plus3=1 if index==3
gen plus4=0
replace plus4=1 if index>=4


gen minus1=0
replace minus1=1 if index==-1
gen minus2=0
replace minus2=1 if index==-2
gen minus3=0
replace minus3=1 if index==-3
gen minus4=0
replace minus4=1 if index==-4
gen minus5=0
replace minus5=1 if index<=-5
ivregress 2sls newpretermLT37 plus0 plus1 plus2 plus3 plus4   minus2 minus3 minus4 minus5 i.year (elig00=simu00) i.birth_month  i.by i.age_cat  i.mom_birth_state   i.tbo i.male   Exitexam Perstudentexpenditure Studentteacherratio Povertyrate Unemploymentrate i.division#c.by   , cluster(mom_birth_state)

matrix V= e(V)
matrix a = V[1..9,1..9]
svmat a

global var1=a1[1]
gen sd1=sqrt($var1)
global var2=a2[2]
gen sd2=sqrt($var2)
global var3=a3[3]
gen sd3=sqrt($var3)
global var4=a4[4]
gen sd4=sqrt($var4)
global var5=a5[5]
gen sd5=sqrt($var5)
global var6=a6[6]
gen sd6=sqrt($var6)
global var7=a7[7]
gen sd7=sqrt($var7)
global var8=a8[8]
gen sd8=sqrt($var8)
global var9=a9[9]
gen sd9=sqrt($var9)

gen lower1=_b[minus3]-(1.96*sd7)
gen upper1=_b[minus3]+(1.96*sd7)

gen order=-3

gen value=_b[minus3]

keep if _n==1

keep lower1 upper1 order value


tempfile conf7

save "`conf7'"


*8


use $data/estimation_sample_whites, clear

gen plus0=0
replace plus0=1 if index==0
gen plus1=0
replace plus1=1 if index==1
gen plus2=0
replace plus2=1 if index==2
gen plus3=0
replace plus3=1 if index==3
gen plus4=0
replace plus4=1 if index>=4


gen minus1=0
replace minus1=1 if index==-1
gen minus2=0
replace minus2=1 if index==-2
gen minus3=0
replace minus3=1 if index==-3
gen minus4=0
replace minus4=1 if index==-4
gen minus5=0
replace minus5=1 if index<=-5
ivregress 2sls newpretermLT37 plus0 plus1 plus2 plus3 plus4   minus2 minus3 minus4 minus5 i.year (elig00=simu00) i.birth_month  i.by i.age_cat  i.mom_birth_state   i.tbo i.male   Exitexam Perstudentexpenditure Studentteacherratio Povertyrate Unemploymentrate i.division#c.by   , cluster(mom_birth_state)

matrix V= e(V)
matrix a = V[1..9,1..9]
svmat a

global var1=a1[1]
gen sd1=sqrt($var1)
global var2=a2[2]
gen sd2=sqrt($var2)
global var3=a3[3]
gen sd3=sqrt($var3)
global var4=a4[4]
gen sd4=sqrt($var4)
global var5=a5[5]
gen sd5=sqrt($var5)
global var6=a6[6]
gen sd6=sqrt($var6)
global var7=a7[7]
gen sd7=sqrt($var7)
global var8=a8[8]
gen sd8=sqrt($var8)
global var9=a9[9]
gen sd9=sqrt($var9)

gen lower1=_b[minus4]-(1.96*sd8)
gen upper1=_b[minus4]+(1.96*sd8)

gen order=-4

gen value=_b[minus4]

keep if _n==1

keep lower1 upper1 order value


tempfile conf8

save "`conf8'"


*9


use $data/estimation_sample_whites, clear

gen plus0=0
replace plus0=1 if index==0
gen plus1=0
replace plus1=1 if index==1
gen plus2=0
replace plus2=1 if index==2
gen plus3=0
replace plus3=1 if index==3
gen plus4=0
replace plus4=1 if index>=4


gen minus1=0
replace minus1=1 if index==-1
gen minus2=0
replace minus2=1 if index==-2
gen minus3=0
replace minus3=1 if index==-3
gen minus4=0
replace minus4=1 if index==-4
gen minus5=0
replace minus5=1 if index<=-5
ivregress 2sls newpretermLT37 plus0 plus1 plus2 plus3 plus4   minus2 minus3 minus4 minus5 i.year (elig00=simu00) i.birth_month  i.by i.age_cat  i.mom_birth_state   i.tbo i.male   Exitexam Perstudentexpenditure Studentteacherratio Povertyrate Unemploymentrate i.division#c.by   , cluster(mom_birth_state)

matrix V= e(V)
matrix a = V[1..9,1..9]
svmat a

global var1=a1[1]
gen sd1=sqrt($var1)
global var2=a2[2]
gen sd2=sqrt($var2)
global var3=a3[3]
gen sd3=sqrt($var3)
global var4=a4[4]
gen sd4=sqrt($var4)
global var5=a5[5]
gen sd5=sqrt($var5)
global var6=a6[6]
gen sd6=sqrt($var6)
global var7=a7[7]
gen sd7=sqrt($var7)
global var8=a8[8]
gen sd8=sqrt($var8)
global var9=a9[9]
gen sd9=sqrt($var9)

gen lower1=_b[minus5]-(1.96*sd9)
gen upper1=_b[minus5]+(1.96*sd9)

gen order=-5

gen value=_b[minus5]

keep if _n==1

keep lower1 upper1 order value


tempfile conf9

save "`conf9'"



*10


use $data/estimation_sample_whites, clear

gen plus0=0
replace plus0=1 if index==0
gen plus1=0
replace plus1=1 if index==1
gen plus2=0
replace plus2=1 if index==2
gen plus3=0
replace plus3=1 if index==3
gen plus4=0
replace plus4=1 if index>=4


gen minus1=0
replace minus1=1 if index==-1
gen minus2=0
replace minus2=1 if index==-2
gen minus3=0
replace minus3=1 if index==-3
gen minus4=0
replace minus4=1 if index==-4
gen minus5=0
replace minus5=1 if index<=-5
ivregress 2sls newpretermLT37 plus0 plus1 plus2 plus3 plus4   minus2 minus3 minus4 minus5 i.year (elig00=simu00) i.birth_month  i.by i.age_cat  i.mom_birth_state   i.tbo i.male   Exitexam Perstudentexpenditure Studentteacherratio Povertyrate Unemploymentrate i.division#c.by   , cluster(mom_birth_state)
gen lower1=0
gen upper1=0
gen order=-1


gen value=0

keep if _n==1

keep lower1 upper1 order value

tempfile conf10

save "`conf10'"

use "`conf1'"

append using "`conf2'"
append using "`conf3'"
append using "`conf4'"
append using "`conf5'"
append using "`conf6'"
append using "`conf7'"
append using "`conf8'"
append using "`conf9'"
append using "`conf10'"



twoway (rcap lower1 upper1 order, lwidth(medium) lcolor(dknavy)) (scatter value order, msize(medium) mcolor(dknavy)), yline(0, lpattern(dash) lcolor(black)) ///
xlabel(-5 "-5+" -4 -3 -2 -1 0 1 2 3 4 "4+")  ylabel( , nogrid) graphregion(fcolor(white) lcolor(none)) legend(off) ///
xtitle("Elapsed Years Relative to Curriculum Change" , height(7)) ytitle(Estimated Effect-Prematurity, height(7))saving(figure_b7_paneld, replace)


*******************************************************************************************************************************************************************



